Change in openvpn[master]: Log OpenSSL errors on failure to set certificate
A message that is not in the archive (sent off-list or not yet received): gerrit.1696183368000.Ic7ec25ac0503a91d5869b8da966d0065f264af22@...2715...
Attention is currently required from: flichtenheld.
Hello flichtenheld,
I'd like you to do a code review.
Please visit
http://gerrit.openvpn.net/c/openvpn/+/363?usp=email
to review the following change.
Change subject: Log OpenSSL errors on failure to set certificate
......................................................................
Log OpenSSL errors on failure to set certificate
Currently we log a bogus error message saying private key password verification failed when SSL_CTX_use_cert_and_key() fails in pkcs11_openssl.c. Instead print OpenSSL error queue and exit promptly.
Also log OpenSSL errors when SSL_CTX_use_certiifcate() fails in cryptoapi.c and elsewhere. Such logging could be useful especially when the ceritficate is rejected by OpenSSL due to stricter security restrictions in recent versions of the library.
---
M src/openvpn/cryptoapi.c
M src/openvpn/pkcs11_openssl.c
M src/openvpn/ssl_openssl.c
M tests/unit_tests/openvpn/test_cryptoapi.c
M tests/unit_tests/openvpn/test_pkcs11.c
5 files changed, 30 insertions(+), 2 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/63/363/1
src/openvpn/cryptoapi.c +2 -0
@@ -51,6 +51,7 @@#include "openssl_compat.h" #include "win32.h" #include "xkey_common.h" +#include "crypto_openssl.h" #ifndef HAVE_XKEY_PROVIDER
@@ -505,6 +506,7 @@if (SSL_CTX_use_certificate (ssl_ctx, cert) &&SSL_CTX_use_PrivateKey (ssl_ctx, privkey)) { +crypto_print_openssl_errors (M_WARN ); ret =1 ; }
src/openvpn/pkcs11_openssl.c +4 -2
@@ -302,7 +302,8 @@if (!SSL_CTX_use_cert_and_key (ctx->ctx, x509, pkey,NULL ,0 )) { -msg (M_WARN ,"PKCS#11: Failed to set cert and private key for OpenSSL" ); +crypto_print_openssl_errors (M_WARN ); +msg (M_FATAL ,"PKCS#11: Failed to set cert and private key for OpenSSL" ); goto cleanup; } ret =1 ;
@@ -369,7 +370,8 @@if (!SSL_CTX_use_certificate (ssl_ctx->ctx, x509)) { -msg (M_WARN ,"PKCS#11: Cannot set certificate for openssl" ); +crypto_print_openssl_errors (M_WARN ); +msg (M_FATAL ,"PKCS#11: Cannot set certificate for openssl" ); goto cleanup; } ret =0 ;
src/openvpn/ssl_openssl.c +2 -0
@@ -857,6 +857,7 @@/* Load Certificate */ if (!SSL_CTX_use_certificate (ctx->ctx, cert)) { +crypto_print_openssl_errors (M_WARN );crypto_msg (M_FATAL ,"Cannot use certificate" ); }
@@ -1007,6 +1008,7 @@ end:if (!ret) { +crypto_print_openssl_errors (M_WARN );if (cert_file_inline) {crypto_msg (M_FATAL ,"Cannot load inline certificate file" );
tests/unit_tests/openvpn/test_cryptoapi.c +11 -0
@@ -58,6 +58,17 @@return NULL ; } +/* replacement for crypto_print_openssl_errors() */ +void +crypto_print_openssl_errors (const unsigned int flags) +{ +unsigned long e; +while ((e =ERR_get_error ())) + { +msg (flags,"OpenSSL error %lu: %s\n" , e,ERR_error_string (e,NULL )); + } +} +/* tls_libctx is defined in ssl_openssl.c which we do not want to compile in */ OSSL_LIB_CTX *tls_libctx;
tests/unit_tests/openvpn/test_pkcs11.c +11 -0
@@ -44,6 +44,17 @@struct management *management;/* global */ +/* replacement for crypto_print_openssl_errors() */ +void +crypto_print_openssl_errors (const unsigned int flags) +{ +unsigned long e; +while ((e =ERR_get_error ())) + { +msg (flags,"OpenSSL error %lu: %s\n" , e,ERR_error_string (e,NULL )); + } +} +/* stubs for some unused functions instead of pulling in too many dependencies */ int parse_line(const char *line, char **p, const int n, const char *file,
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/363?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic7ec25ac0503a91d5869b8da966d0065f264af22
Gerrit-Change-Number: 363
Gerrit-PatchSet: 1
Gerrit-Owner: selvanair <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newchange
Attention is currently required from: flichtenheld.
Hello flichtenheld,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/363?usp=email
to look at the new patch set (#2).
Change subject: Log OpenSSL errors on failure to set certificate
......................................................................
Log OpenSSL errors on failure to set certificate
Currently we log a bogus error message saying private key password verification failed when SSL_CTX_use_cert_and_key() fails in pkcs11_openssl.c. Instead print OpenSSL error queue and exit promptly.
Also log OpenSSL errors when SSL_CTX_use_certiifcate() fails in cryptoapi.c and elsewhere. Such logging could be useful especially when the ceritficate is rejected by OpenSSL due to stricter security restrictions in recent versions of the library.
---
M src/openvpn/cryptoapi.c
M src/openvpn/pkcs11_openssl.c
M src/openvpn/ssl_openssl.c
M tests/unit_tests/openvpn/test_cryptoapi.c
M tests/unit_tests/openvpn/test_pkcs11.c
5 files changed, 32 insertions(+), 2 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/63/363/2
src/openvpn/cryptoapi.c +2 -0
@@ -51,6 +51,7 @@#include "openssl_compat.h" #include "win32.h" #include "xkey_common.h" +#include "crypto_openssl.h" #ifndef HAVE_XKEY_PROVIDER
@@ -505,6 +506,7 @@if (SSL_CTX_use_certificate (ssl_ctx, cert) &&SSL_CTX_use_PrivateKey (ssl_ctx, privkey)) { +crypto_print_openssl_errors (M_WARN ); ret =1 ; }
src/openvpn/pkcs11_openssl.c +4 -2
@@ -302,7 +302,8 @@if (!SSL_CTX_use_cert_and_key (ctx->ctx, x509, pkey,NULL ,0 )) { -msg (M_WARN ,"PKCS#11: Failed to set cert and private key for OpenSSL" ); +crypto_print_openssl_errors (M_WARN ); +msg (M_FATAL ,"PKCS#11: Failed to set cert and private key for OpenSSL" ); goto cleanup; } ret =1 ;
@@ -369,7 +370,8 @@if (!SSL_CTX_use_certificate (ssl_ctx->ctx, x509)) { -msg (M_WARN ,"PKCS#11: Cannot set certificate for openssl" ); +crypto_print_openssl_errors (M_WARN ); +msg (M_FATAL ,"PKCS#11: Cannot set certificate for openssl" ); goto cleanup; } ret =0 ;
src/openvpn/ssl_openssl.c +2 -0
@@ -857,6 +857,7 @@/* Load Certificate */ if (!SSL_CTX_use_certificate (ctx->ctx, cert)) { +crypto_print_openssl_errors (M_WARN );crypto_msg (M_FATAL ,"Cannot use certificate" ); }
@@ -1007,6 +1008,7 @@ end:if (!ret) { +crypto_print_openssl_errors (M_WARN );if (cert_file_inline) {crypto_msg (M_FATAL ,"Cannot load inline certificate file" );
tests/unit_tests/openvpn/test_cryptoapi.c +11 -0
@@ -58,6 +58,17 @@return NULL ; } +/* replacement for crypto_print_openssl_errors() */ +void +crypto_print_openssl_errors (const unsigned int flags) +{ +unsigned long e; +while ((e =ERR_get_error ())) + { +msg (flags,"OpenSSL error %lu: %s\n" , e,ERR_error_string (e,NULL )); + } +} +/* tls_libctx is defined in ssl_openssl.c which we do not want to compile in */ OSSL_LIB_CTX *tls_libctx;
tests/unit_tests/openvpn/test_pkcs11.c +13 -0
@@ -44,6 +44,19 @@struct management *management;/* global */ +/* replacement for crypto_print_openssl_errors() */ +#if defined (ENABLE_CRYPTO_OPENSSL ) +void +crypto_print_openssl_errors (const unsigned int flags) +{ +unsigned long e; +while ((e =ERR_get_error ())) + { +msg (flags,"OpenSSL error %lu: %s\n" , e,ERR_error_string (e,NULL )); + } +} +#endif +/* stubs for some unused functions instead of pulling in too many dependencies */ int parse_line(const char *line, char **p, const int n, const char *file,
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/363?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic7ec25ac0503a91d5869b8da966d0065f264af22
Gerrit-Change-Number: 363
Gerrit-PatchSet: 2
Gerrit-Owner: selvanair <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newpatchset
Attention is currently required from: flichtenheld.
selvanair has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/363?usp=email )
Change subject: Log OpenSSL errors on failure to set certificate
......................................................................
Patch Set 2: Code-Review+2
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/363?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic7ec25ac0503a91d5869b8da966d0065f264af22
Gerrit-Change-Number: 363
Gerrit-PatchSet: 2
Gerrit-Owner: selvanair <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: selvanair <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Sun, 01 Oct 2023 19:07:53 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
Attention is currently required from: flichtenheld.
selvanair has removed a vote from this change. ( http://gerrit.openvpn.net/c/openvpn/+/363?usp=email )
Change subject: Log OpenSSL errors on failure to set certificate
......................................................................
Removed Code-Review+2 by selvanair <[email protected]...>
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/363?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic7ec25ac0503a91d5869b8da966d0065f264af22
Gerrit-Change-Number: 363
Gerrit-PatchSet: 2
Gerrit-Owner: selvanair <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: selvanair <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: deleteVote
cron2 has uploaded a new patch set (#3) to the change originally created by selvanair. ( http://gerrit.openvpn.net/c/openvpn/+/363?usp=email )
Change subject: Log OpenSSL errors on failure to set certificate
......................................................................
Log OpenSSL errors on failure to set certificate
Currently we log a bogus error message saying private key password verification failed when SSL_CTX_use_cert_and_key() fails in pkcs11_openssl.c. Instead print OpenSSL error queue and exit promptly.
Also log OpenSSL errors when SSL_CTX_use_certiifcate() fails in cryptoapi.c and elsewhere. Such logging could be useful especially when the ceritficate is rejected by OpenSSL due to stricter security restrictions in recent versions of the library.
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg27122.html
---
M src/openvpn/cryptoapi.c
M src/openvpn/pkcs11_openssl.c
M src/openvpn/ssl_openssl.c
M tests/unit_tests/openvpn/test_cryptoapi.c
M tests/unit_tests/openvpn/test_pkcs11.c
5 files changed, 30 insertions(+), 2 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/63/363/3
src/openvpn/cryptoapi.c +2 -0
@@ -51,6 +51,7 @@#include "openssl_compat.h" #include "win32.h" #include "xkey_common.h" +#include "crypto_openssl.h" #ifndef HAVE_XKEY_PROVIDER
@@ -505,6 +506,7 @@if (SSL_CTX_use_certificate (ssl_ctx, cert) &&SSL_CTX_use_PrivateKey (ssl_ctx, privkey)) { +crypto_print_openssl_errors (M_WARN ); ret =1 ; }
src/openvpn/pkcs11_openssl.c +4 -2
@@ -302,7 +302,8 @@if (!SSL_CTX_use_cert_and_key (ctx->ctx, x509, pkey,NULL ,0 )) { -msg (M_WARN ,"PKCS#11: Failed to set cert and private key for OpenSSL" ); +crypto_print_openssl_errors (M_WARN ); +msg (M_FATAL ,"PKCS#11: Failed to set cert and private key for OpenSSL" ); goto cleanup; } ret =1 ;
@@ -369,7 +370,8 @@if (!SSL_CTX_use_certificate (ssl_ctx->ctx, x509)) { -msg (M_WARN ,"PKCS#11: Cannot set certificate for openssl" ); +crypto_print_openssl_errors (M_WARN ); +msg (M_FATAL ,"PKCS#11: Cannot set certificate for openssl" ); goto cleanup; } ret =0 ;
src/openvpn/ssl_openssl.c +2 -0
@@ -857,6 +857,7 @@/* Load Certificate */ if (!SSL_CTX_use_certificate (ctx->ctx, cert)) { +crypto_print_openssl_errors (M_WARN );crypto_msg (M_FATAL ,"Cannot use certificate" ); }
@@ -1007,6 +1008,7 @@ end:if (!ret) { +crypto_print_openssl_errors (M_WARN );if (cert_file_inline) {crypto_msg (M_FATAL ,"Cannot load inline certificate file" );
tests/unit_tests/openvpn/test_cryptoapi.c +11 -0
@@ -58,6 +58,17 @@return NULL ; } +/* replacement for crypto_print_openssl_errors() */ +void +crypto_print_openssl_errors (const unsigned int flags) +{ +unsigned long e; +while ((e =ERR_get_error ())) + { +msg (flags,"OpenSSL error %lu: %s\n" , e,ERR_error_string (e,NULL )); + } +} +/* tls_libctx is defined in ssl_openssl.c which we do not want to compile in */ OSSL_LIB_CTX *tls_libctx;
tests/unit_tests/openvpn/test_pkcs11.c +11 -0
@@ -44,6 +44,17 @@struct management *management;/* global */ +/* replacement for crypto_print_openssl_errors() */ +void +crypto_print_openssl_errors (const unsigned int flags) +{ +unsigned long e; +while ((e =ERR_get_error ())) + { +msg (flags,"OpenSSL error %lu: %s\n" , e,ERR_error_string (e,NULL )); + } +} +/* stubs for some unused functions instead of pulling in too many dependencies */ int parse_line(const char *line, char **p, const int n, const char *file,
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/363?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic7ec25ac0503a91d5869b8da966d0065f264af22
Gerrit-Change-Number: 363
Gerrit-PatchSet: 3
Gerrit-Owner: selvanair <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: selvanair <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: newpatchset
cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/363?usp=email )
Change subject: Log OpenSSL errors on failure to set certificate
......................................................................
Log OpenSSL errors on failure to set certificate
Currently we log a bogus error message saying private key password verification failed when SSL_CTX_use_cert_and_key() fails in pkcs11_openssl.c. Instead print OpenSSL error queue and exit promptly.
Also log OpenSSL errors when SSL_CTX_use_certiifcate() fails in cryptoapi.c and elsewhere. Such logging could be useful especially when the ceritficate is rejected by OpenSSL due to stricter security restrictions in recent versions of the library.
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg27122.html
---
M src/openvpn/cryptoapi.c
M src/openvpn/pkcs11_openssl.c
M src/openvpn/ssl_openssl.c
M tests/unit_tests/openvpn/test_cryptoapi.c
M tests/unit_tests/openvpn/test_pkcs11.c
5 files changed, 30 insertions(+), 2 deletions(-)
src/openvpn/cryptoapi.c +2 -0
@@ -51,6 +51,7 @@#include "openssl_compat.h" #include "win32.h" #include "xkey_common.h" +#include "crypto_openssl.h" #ifndef HAVE_XKEY_PROVIDER
@@ -505,6 +506,7 @@if (SSL_CTX_use_certificate (ssl_ctx, cert) &&SSL_CTX_use_PrivateKey (ssl_ctx, privkey)) { +crypto_print_openssl_errors (M_WARN ); ret =1 ; }
src/openvpn/pkcs11_openssl.c +4 -2
@@ -302,7 +302,8 @@if (!SSL_CTX_use_cert_and_key (ctx->ctx, x509, pkey,NULL ,0 )) { -msg (M_WARN ,"PKCS#11: Failed to set cert and private key for OpenSSL" ); +crypto_print_openssl_errors (M_WARN ); +msg (M_FATAL ,"PKCS#11: Failed to set cert and private key for OpenSSL" ); goto cleanup; } ret =1 ;
@@ -369,7 +370,8 @@if (!SSL_CTX_use_certificate (ssl_ctx->ctx, x509)) { -msg (M_WARN ,"PKCS#11: Cannot set certificate for openssl" ); +crypto_print_openssl_errors (M_WARN ); +msg (M_FATAL ,"PKCS#11: Cannot set certificate for openssl" ); goto cleanup; } ret =0 ;
src/openvpn/ssl_openssl.c +2 -0
@@ -857,6 +857,7 @@/* Load Certificate */ if (!SSL_CTX_use_certificate (ctx->ctx, cert)) { +crypto_print_openssl_errors (M_WARN );crypto_msg (M_FATAL ,"Cannot use certificate" ); }
@@ -1007,6 +1008,7 @@ end:if (!ret) { +crypto_print_openssl_errors (M_WARN );if (cert_file_inline) {crypto_msg (M_FATAL ,"Cannot load inline certificate file" );
tests/unit_tests/openvpn/test_cryptoapi.c +11 -0
@@ -58,6 +58,17 @@return NULL ; } +/* replacement for crypto_print_openssl_errors() */ +void +crypto_print_openssl_errors (const unsigned int flags) +{ +unsigned long e; +while ((e =ERR_get_error ())) + { +msg (flags,"OpenSSL error %lu: %s\n" , e,ERR_error_string (e,NULL )); + } +} +/* tls_libctx is defined in ssl_openssl.c which we do not want to compile in */ OSSL_LIB_CTX *tls_libctx;
tests/unit_tests/openvpn/test_pkcs11.c +11 -0
@@ -44,6 +44,17 @@struct management *management;/* global */ +/* replacement for crypto_print_openssl_errors() */ +void +crypto_print_openssl_errors (const unsigned int flags) +{ +unsigned long e; +while ((e =ERR_get_error ())) + { +msg (flags,"OpenSSL error %lu: %s\n" , e,ERR_error_string (e,NULL )); + } +} +/* stubs for some unused functions instead of pulling in too many dependencies */ int parse_line(const char *line, char **p, const int n, const char *file,
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/363?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic7ec25ac0503a91d5869b8da966d0065f264af22
Gerrit-Change-Number: 363
Gerrit-PatchSet: 3
Gerrit-Owner: selvanair <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: selvanair <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: merged